package com.smart.five.ioc.java.configuration.xml;

import com.smart.five.ioc.java.configuration.LoginDao;
import com.smart.five.ioc.java.configuration.LoginService;
import com.smart.five.ioc.java.configuration.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

@Configuration
//@Configuration可以通过ImportResource引入xml配置文件，在配置类中可以直接通过@Autowired引用xml配置文件中定义的bean
@ImportResource("classpath:com/smart/five/ioc/java/configuration/xml/beans1.xml")
public class LoginAppConf {

    @Bean
    @Autowired
    public LoginService loginService(UserDao userDao, LoginDao loginDao){
        LoginService loginService = new LoginService();
        loginService.setUserDao(userDao);
        loginService.setLoginDao(loginDao);
        return loginService;
    }

}
